package com.example.xuegengwang.xuegengwang.wxapi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.example.xuegengwang.xuegengwang.R;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

import org.xutils.view.annotation.ContentView;

import common.Constant;
import utils.MyLogUtils;
import utils.ToastUtils;

/**
 * Created by Administrator on 2017/4/24.
 */
public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {

    private IWXAPI api;
    private static final String TAG = "WXPayEntryActivity";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        api = WXAPIFactory.createWXAPI(this, Constant.WEIXIN_APP_ID);
        api.handleIntent(getIntent(), this);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        api.handleIntent(intent, this);
    }

    @Override
    public void onReq(BaseReq req) {
    }

    @Override
    public void onResp(BaseResp resp) {
        int code = resp.errCode;
        Intent i = new Intent();
        i.putExtra("code",code);
        i.setAction(Constant.WEIXIN_ACITION_HASPAY);
        sendBroadcast(i);

        WXPayEntryActivity.this.finish();
    }


}
